package com.hanock.sm.activity;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

public abstract class AbstractActivity extends Activity {
	
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Log.i("test2", "onCreate:" + getClass().getSimpleName());
	}
	
	@Override
	protected void onStart() {
		super.onStart();
		
		Log.i("test2", "onStart:" + getClass().getSimpleName());
		
		/*if ( ! Application.getInstance().isInitialized() 
				&& getClass() != MainActivity.class){
			reboot();
		}*/
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		
		Log.i("test2", "onPause:" + getClass().getSimpleName());
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		
		Log.i("test2", "onResume:" + getClass().getSimpleName());
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		
		Log.i("test2", "onStop:" + getClass().getSimpleName());
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		
		Log.i("test2", "onDestroy:" + getClass().getSimpleName());
	}
	
	@Override
	public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
		
		Log.i("test2", "onWindowFocusChanged:" + hasFocus + ":" + getClass().getSimpleName());
	}

	protected void reboot(){
		Intent intent = new Intent(getApplicationContext(), MainActivity.class);
		finish();
		startActivity(intent);
	}
	
	protected void startActivity(Class<? extends Activity> activityClass){
		startActivity(new Intent(getApplicationContext(), activityClass));
		overridePendingTransition(0, 0);
	}
	
	protected void startActivity(Class<? extends Activity> activityClass, Bundle data){
		Intent intent = new Intent(getApplicationContext(), activityClass);
		intent.putExtras(data);
		startActivity(intent);
		overridePendingTransition(0, 0);
	}
	
	protected void finishActivity(){
		finish();
		overridePendingTransition(0, 0);
	}
}




